package com.wdl.sm.webui.yang.type;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.nokia.taiji.yang.schema.YangType;

/**
 * For type node, the supported extensions are "alu:if" and "alu:path".
 * "alu:if" has expression, we'll build it in its parent schema node.
 * "alu:path" would force the type to be "leafref" and it would be handled there.
 */
public abstract class NormalizedValue {
    protected static final Logger LOG = LoggerFactory.getLogger("NormalizedValue");

    String type;
    String tag;

    String defaultValue;
    String value;
    String units;

    // List to hold all "alu:if" statements
    List<String> conditions = new ArrayList<String>();

    public NormalizedValue(YangType input) {
        defaultValue = input.getDefaultValue();
        tag = type = input.getName().toString();
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Object getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getUnits() {
        return units;
    }

    public void setUnits(String units) {
        this.units = units;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }
    
    public void addCondition(String condition) {
        if (!conditions.contains(condition)) {
            conditions.add(condition);
        }
    }

    public List<String> getConditions() {
        return conditions;
    }

    public void setConditions(List<String> conditions) {
        if (conditions != null) {
            this.conditions = conditions;
        }
    }
}